package com.lin.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @ClassName Login
 * @Description
 * @Author lin
 * @Date 2021/12/6 下午9:51
 * @Version V1.0
 */
@Controller
public class Login {
    @PostMapping("/userServlet")
    public String hello(@RequestParam String username,@RequestParam String password, HttpSession session){
        System.out.println(username);
        System.out.println(password);
        if(username.equals("zhangsan")&&password.equals("123456")){
            session.setAttribute("user",username);
            session.setAttribute("msg","欢迎尊敬的用户 "+username);
            return "vipWelcomePage.html";
        }else{
            session.setAttribute("msg","账户或密码错误！！！");
            return "redirect:http://localhost:8080/login.html";
        }
    }
}
